<template>
	<view class="spay">
		<uni-nav-bar class="uni-nav-bar" color="#ffffff" left-icon="left" @clickLeft="togo" title="开通会员权益"
			:border="false" fixed statusBar></uni-nav-bar>
		<view class="headerview">
			<view class="bgtop"></view>
			<view class="bgbottom"></view>
			<view class="showborder">
				<view class="title">会员优惠额度(元)</view>
				<view class="price">{{Number(userInfo.discounts).toFixed(2)}}</view>
				<view class="btn" @click="tourl">充值额度</view>
			</view>
		</view>
		<view class="listbox">
			<view class="title">额度变更明细</view>
			<view v-if="listData.length">
				<view class="list" v-for="(item,index) in listData" :key="index">
					<view class="toplist">
						<text>{{item.remark}}</text>
						<text v-show="item.amount > 0">+¥{{item.amount}}</text>
						<text v-show="item.amount <= 0">{{item.amount}}</text>
					</view>
					<view class="buttonlist">
						<text>{{item.time}}</text>
						<text>余额 {{item.hamount}}元</text>
					</view>
				</view>
			</view>
			<view v-else>暂无明细</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex'
	export default {
		data() {
			return {
				listData: [],
				select: 0,
				isselect: false,
				pageNum: 1,
				pageSize: 20,
			}
		},
		onReachBottom() {
			if (this.loadMore) {
				this.pageNum = this.pageNum + 1
				this.getList()
			}
		},
		onShow() {
			this.listData = [];
			this.getUserInfo()
			this.getList()
		},
		computed: {
			...mapState(['userInfo'])
		},
		methods: {
			...mapActions(['getUserInfo']),
			async getList() {
				const data = await this.$apis.user.getBalance({
					pageNum: this.pageNum,
					pageSize: this.pageSize,
					type: 4
				})
				this.listData = [...this.listData, ...data.rows]
				if (this.listData.length >= data.total) {
					this.loadMore = false
				}
			},
			togo() {
				uni.navigateBack(-1)
			},
			tourl() {
				uni.navigateTo({
					url: '/pages/mine/member/edpay'
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.spay {
		height: 100%;
		background-color: #f5f5f5;

		.headerview {
			height: 442rpx;
			overflow: hidden;
			padding-top: 48rpx;
			box-sizing: border-box;
			position: relative;

			.bgtop {
				position: absolute;
				top: 0%;
				left: 0;
				width: 100%;
				height: 296rpx;
				background-image: linear-gradient(to right, #363B53, #5B5E74);
			}

			.showborder {
				width: 702rpx;
				height: 394rpx;
				background-color: #ffffff;
				border-radius: 24rpx;
				position: absolute;
				bottom: 0%;
				left: 50%;
				margin-left: -351rpx;
				color: #333333;
				padding: 48rpx 0 36rpx 0;
				box-sizing: border-box;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				flex-direction: column;

				.title {
					font-size: 30rpx;
					height: 42rpx;
				}

				.price {
					font-size: 90rpx;
					margin-top: 24rpx;
					height: 84rpx;
					font-weight: 700;
				}

				.btn {
					background-image: linear-gradient(to right, #FFE5C2, #F1C68E);
					border-radius: 96rpx;
					height: 96rpx;
					width: 630rpx;
					color: #3F3F47;
					margin-top: 64rpx;
					font-weight: 700;
					display: flex;
					justify-content: center;
					align-items: center;
				}
			}
		}

		.listbox {
			padding: 32rpx;
			background-color: #ffffff;
			border-radius: 24rpx;
			box-sizing: border-box;
			margin: 40rpx 20rpx 0;

			.title {
				font-size: 700;
				color: #333333;
				font-size: 30rpx;
			}

			.list {
				height: 134rpx;
				padding: 28rpx 0 24rpx;
				box-sizing: border-box;
				border-bottom: 2rpx solid #F2F2F5;

				.toplist {
					display: flex;
					justify-content: space-between;
					align-items: center;
					height: 44rpx;

					text {
						font-weight: 700;

						&:nth-of-type(1) {
							color: #000000;
							font-size: 26rpx;
						}

						&:nth-of-type(2) {
							color: #FB4041;
							font-size: 30rpx;
						}

						&:nth-of-type(3) {
							color: #2FCC71;
							font-size: 30rpx;
						}
					}
				}

				.buttonlist {
					margin-top: 5rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;

					text {
						color: rgba(0, 0, 0, .4);
						font-size: 24rpx;
					}
				}

				&:last-child {
					border: none;
				}
			}
		}
	}
</style>

<style lang="scss">
	.uni-navbar__content {
		background-image: linear-gradient(to right, #363B53, #5B5E74);
	}

	label {
		display: flex;
		align-items: center;
	}

	.uni-navbar__header {
		background-color: transparent !important;
	}

	.uni-nav-bar-text {
		font-size: 32rpx !important;
	}
</style>